package cn.org.farseer.sweetftp.core;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import cn.org.farseer.sweetftp.core.util.SweetFTPConstants;

/**
 * 作者 : [Farseer.org] 简洋  —  2009-8-21
 * 
 * 项目 : [Farseer.org] SweetFTP
 *
 * 说明：
 */
public class FTPConfiguration
{
	private FTPContext context;
	private ApplicationContext applicationContext;
	private static final Log logger = LogFactory.getLog(FTPConfiguration.class);
	
	
	public FTPConfiguration()
	{
		applicationContext = new ClassPathXmlApplicationContext(SweetFTPConstants.SPRING_CONFIG_FILE_NAME);
		logger.debug("applicationContext 对象状态 ： " + applicationContext);
	}
	
	
	public FTPContext getFTPContext()
	{
		context = (FTPContext)this.getBean(FTPContext.class);
		context.setConfiguration(this);
		return context;
	}
	
	public Object getBean(Class clazz)
	{
		return applicationContext.getBean(clazz.getName());
	}
	
	public Object getBean(String name)
	{
		return applicationContext.getBean(name);
	}
	
	public ApplicationContext getApplicationContext()
	{
		return applicationContext;
	}
	
}
